package cn.admin.controller;

import cn.admin.config.key.StatusCode;
import cn.admin.service.PayPhotoUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author: 毛苏宇
 * @Description: You can do it!
 * @Date: Create in 14:40 2019/3/23
 */
@Controller
@RequestMapping("/pay")
public class PayPhotoUploadController {


    @Autowired
    private PayPhotoUploadService payPhotoUploadService;

    @GetMapping("/photo")
    public String payPhoto() {
        return "/photo";
    }


    @PostMapping("/photo.do")
    @ResponseBody
    public String doPhoto(@RequestParam("data") String data, HttpServletRequest request) {
        if (!data.equals("") && null != data) {
            boolean b = payPhotoUploadService.saveImg(data, request);
            if (b) {
                return StatusCode.STATUS_SUCCESS;
            }
            return StatusCode.STATUS_FAIL;
        } else {
            return StatusCode.STATUS_NULL;
        }
    }

}
